// 开发文档：https://uniapp.dcloud.io/uniCloud/clientdb?id=action
module.exports = {
	before: async (state, event) => {
		let qrcodeText = 'http://applet.wmeizi.com/quickpay'+state.newData.app_id+'?shopId='+state.newData.shop_id+'&gathering='+state.newData.number;
		let qrcodeErrorCorrectLevel = 'M';
		let qrcodeMargin = 2;
		let callFunctionResult = await uniCloud.callFunction({
			name: 'explain-qrcode',
			data: {
				service: 'qrcode',
				action: 'make',
				params: {
					text: qrcodeText,
					ec_level: qrcodeErrorCorrectLevel,
					margin: qrcodeMargin
				}
			}
		});
		if(callFunctionResult.result){
			state.newData.make_code=callFunctionResult.result
		} 
	},
	after: async (state, event, error, result) => {
		if (error) {
			throw error
		}
		return result
	}
}
